package ace.module.account.core.impl.service.biz.impl;

import ace.module.account.api.model.dto.IamAccountPasswordDto;
import ace.module.account.core.impl.converter.IamAccountPasswordConverter;
import ace.module.account.core.impl.dao.entity.IamAccountPassword;
import ace.module.account.core.impl.dao.repository.IamAccountPasswordRepository;
import ace.module.account.core.impl.service.biz.IamAccountPasswordBiz;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author caspar
 * @date 2023/3/20 9:28
 */
@AllArgsConstructor
@Slf4j
@Component
public class IamAccountPasswordBizImpl implements IamAccountPasswordBiz {
  private final IamAccountPasswordRepository accountPasswordMapper;
  private final IamAccountPasswordConverter accountPasswordConverter;

  public IamAccountPasswordDto getFromCollectionById(
      Long id, List<IamAccountPassword> findAccountPasswordList) {

    IamAccountPassword accountPassword =
        findAccountPasswordList.stream()
            .filter(p -> p.getIamAccountId().equals(id))
            .findFirst()
            .orElse(null);
    IamAccountPasswordDto accountPasswordDTO =
        this.accountPasswordConverter.convert(accountPassword);
    return accountPasswordDTO;
  }
}
